<!DOCTYPE html>
<html th:replace="~{layout :: layout(~{::title}, ~{::section})}">
<head>
<title>学校编辑页面</title>

</head>
<body>
	<section>
		<link th:href="@{/zui/lib/uploader/zui.uploader.min.css}"
			rel="stylesheet">
		<form th:action="@{/admin/school/edit}" method="post">
			<div class="row">
				<div class="col-xs-2"
					style="height: 35px; display: flex; justify-content: flex-end; line-height: 35px">
					选择地区</div>
				<div class="col-xs-6" style="display: flex;">
					<select class="form-control" name="province">
					    <option value="0">选择省|直辖市</option>
						<option value="1">泉州信息工程学院</option>
						<option value="2">泉州师范学院软件学院</option>
					</select>
					<select class="form-control" name="city">
					    <option value="0">选择地级市|市辖区</option>
						<option value="1">泉州信息工程学院</option>
						<option value="2">泉州师范学院软件学院</option>
					</select>
					<select class="form-control" name="area">
					    <option value="0">选择县|地级市辖区</option>
						<option value="1">泉州信息工程学院</option>
						<option value="2">泉州师范学院软件学院</option>
					</select>
				</div>
				<div class="col-xs-4"></div>
			</div>
			<div class="row">
				<div class="col-xs-2"
					style="height: 35px; display: flex; justify-content: flex-end; line-height: 35px">
					学校名称</div>
				<div class="col-xs-6">
					<input class="form-control" type="text" placeholder="请输入学校名称"
						name="schoolName">
				</div>
				<div class="col-xs-4"></div>
			</div>
			<div class="row">
				<div class="col-xs-2"
					style="height: 35px; display: flex; justify-content: flex-end; line-height: 35px">
					是否激活</div>
				<div class="col-xs-6">
					<select class="form-control" name="depart">
						<option value="0">未启用</option>
						<option value="1" selected="selected">启用</option>
					</select>
				</div>
				<div class="col-xs-4"></div>
			</div>
			<div class="row">
				<div class="col-xs-2"
					style="height: 35px; display: flex; justify-content: flex-end; line-height: 35px">
					学校地址</div>
				<div class="col-xs-6">
					<input class="form-control" type="text" placeholder="请输入学校地址"
						name="address">
				</div>
				<div class="col-xs-4"></div>
			</div>
			<div class="row">
				<div class="col-xs-2"
					style="height: 35px; display: flex; justify-content: flex-end; line-height: 35px">
					社团介绍</div>
				<div class="col-xs-10">
					<textarea id="decription" name="description"
						class="form-control kindeditor"></textarea>
				</div>

			</div>
			<div class="row">
				<div class="col-xs-2"
					style="height: 35px; display: flex; justify-content: flex-end; line-height: 35px">
					</div>
				<div class="col-xs-6">
					<button class="btn btn-primary btn-block" type="submit">保存</button>
				</div>
				<div class="col-xs-4"></div>
			</div>

		</form>


		<script type="text/javascript"
			th:src="@{/zui/lib/tinymce/js/tinymce/tinymce.min.js}"></script>

		<script type="text/javascript"
			th:src="@{/zui/lib/uploader/zui.uploader.min.js}"></script>

		<script type="text/javascript">
			tinymce.init({
				selector : '#decription',
				height : 400,
				language : 'zh_CN',
				plugins : ['advlist','autolink','link','image'], //数组方式
				toolbar: false,
				images_upload_handler: function (blobInfo, succFun, failFun) {
			        var xhr, formData;
			        var file = blobInfo.blob();//转化为易于理解的file对象
			        xhr = new XMLHttpRequest();
			        xhr.withCredentials = false;
			        xhr.open('POST', '/admin/upload/cosupload');
			        xhr.onload = function() {
			            var json;
			            if (xhr.status != 200) {
			                failFun('HTTP Error: ' + xhr.status);
			                return;
			            } 
			            json =JSON.parse(xhr.responseText);
			           /*  if (!json || typeof json.location != 'string') {
			                failFun('Invalid JSON: ' + xhr.responseText);
			                return;
			            } */
		
			   
			            if(json.status==1){
			            	
			            	//console.log(json.path)
				            succFun(json.path);
			            }
			            else{
			            	 failFun('Invalid JSON: ' + xhr.responseText);
				              return;
			            	
			            }
			            
			        };
			        formData = new FormData();
			        formData.append('file', file, file.name );//此处与源文档不一样
			        xhr.send(formData);
			    }

			})

			
		</script>
	</section>
</body>
</html>